import { request } from "@/utils/http";
import type {
  findScheduleListType,
  getHospitalDepartmentListType,
  getHospitalDetailType,
  getProvinceListReturnType,
  getScheduleRuleListParamsType,
  getScheduleRuleReturnType,
  hospitalListReqReturnType,
  searchHospitalParamsType,
} from "./model/hospitalListTypes";

export const getHospitalListRequest = (
  page: number,
  limit: number,
  search?: searchHospitalParamsType
) => {
  return request.get<any, hospitalListReqReturnType>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: search,
    }
  );
};

export const getProvinceListRequest = () => {
  return request.get<any, getProvinceListReturnType>(
    "/admin/cmn/dict/findByDictCode/province"
  );
};

export const getCityDistrictListRequest = (id: string) => {
  return request.get<any, getProvinceListReturnType>(
    `/admin/cmn/dict/findByParentId/${id}`
  );
};

export const changeStatusRequest = (id: string, status: 0 | 1) => {
  return request.get<any, null>(
    `/admin/hosp/hospital/updateStatus/${id}/${status}`
  );
};

export const getHospitalDetailRequest = (id: string) => {
  return request.get<any, getHospitalDetailType>(
    `/admin/hosp/hospital/show/${id}`
  );
};

export const getHospitalDepartmentRequest = (hoscode: string) => {
  return request.get<any, getHospitalDepartmentListType>(
    `/admin/hosp/department/${hoscode}`
  );
};

export const getScheduleRuleListRequest = ({
  page,
  limit,
  hoscode,
  depcode,
}: getScheduleRuleListParamsType) => {
  return request.get<any, getScheduleRuleReturnType>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  );
};

export const findScheduleListRequest = (
  hoscode: string,
  depcode: string,
  workDate: string
) => {
  return request.get<any,findScheduleListType>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  );
};
